package com.ruoyi.web.controller.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.question.domain.QZoom;
import com.ruoyi.question.service.IQZoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/zoom")
public class ZoomApiController {
    @Autowired private IQZoomService zoomService;
    @GetMapping("/{zoomCode}")
    public AjaxResult startZoom(@PathVariable String zoomCode){
        QZoom zoom=zoomService.lambdaQuery().select(QZoom::getId).eq(QZoom::getCode,zoomCode).eq(QZoom::getIsOver,false).one();
        if(zoom==null){
            return AjaxResult.error("不存在该房间号或比赛已结束");
        }
        return AjaxResult.success(zoom);
    }
}
